/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package mk_tools;

import java.awt.Color;
import java.awt.Graphics2D;

/**
 *
 * @author Mikael Köhlmyr, 2009
 */

public class Rectangle extends java.awt.Rectangle{
    Point[] point = new Point[4];


    public Rectangle(Point uLeft, Point lRight){
    x = uLeft.x;
    y= uLeft.y;
    height = lRight.y - uLeft.y;
    width = lRight.x - uLeft.x;
        point[0] = uLeft;
        point[1] = new Point(lRight.x, uLeft.y);
        point[2] = new Point(uLeft.x, lRight.y);
        point[3] = lRight;
    }

    // skulle kunna användit Rectangle.contains() men jag vill ha separat koll på yttersta raden pixlar och de inre
    public boolean inBounds(int posx, int posy){
        // y blir högre neråt
            if( ( (posx > x) && (posx < x + width) ) && ( (posy > y) && (posy < y + height) ) ){
                return true;
            }
        return false;
    }

    public boolean onBounds(int posx, int posy){
        if((contains(posx, posy)) && !inBounds(posx, posy)){
            // we are ON bounds :))
            return true;
        }
        return false;
    }

    public void paint(Graphics2D g){
        g.setColor(Color.red);
        g.fill(this);
    }
}
